public class ThreadDemo14 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() ->{
            for (int i = 0; i < 5; i++) {
                System.out.println("该线程正在工作！");
                try {
                    Thread.sleep(1000); //在for循环中一秒执行一次，共计执行五秒
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("该线程执行结束！");
        });
        t.start(); //在调用start之后将上下兵分两路分别执行
        t.join(); //该操作就是线程等待

        System.out.println("主线程，在最后打印");
    }
}